package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.Artisan;
import com.weipai.springboot.model.Customer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;
import java.util.Map;

/**
 * 技工
 */
public interface ArtisanMapper{

    int deleteByPrimaryKey(String artisanId);

    int insert(Artisan record);

    int insertSelective(Artisan record);

    Artisan selectByPrimaryKey(String artisanId);

    int updateByPrimaryKeySelective(Artisan record);

    int updateByPrimaryKey(Artisan record);

    //分页查询
    List<Map<String, Object>> selectAllByDel(@Param("del") int del, @Param("search") String search,
                                  @Param("sort") String sort, @Param("way") String way,
                                  @Param("isAudit") String isAudit , @Param("demandCategoryId") String demandCategoryId);

    //技工的详情
    Artisan getArtisanById(String id);


    //删除
    @Update("update c_artisan set artisan_del=-1, del_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
            "where artisan_id=#{id}")
    int updateDel(String id);

    //批量删除
    int batchDeleteById(String[] id);

    //技工的审核
    @Update("update c_artisan set artisan_status=#{status}, update_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
            "where artisan_id=#{id}")
    int updateStatus(@Param("id") String id, @Param("status") Integer status);

    //首页推荐技工
    List<Map<String,Object>> recommendArtisan(String city);

    //根据用户id查询技工信息
    Artisan getArtisanByCustomerId(String customerId);

    Artisan getArtisanByMobile(String mobile);

    @Update("update c_artisan set is_audit=#{isAudit}, update_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
            "where artisan_id=#{id}")
    int changeIsAudit(@Param("id")String id, @Param("isAudit")Integer isAudit);


}